{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-input-inline">
                            <input type="text"  name="start" onclick="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册开始日期" />
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  name="end" onclick="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册结束日期" />
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="key" class="layui-input search" name="key" value="" placeholder="用户名/真实姓名"/>
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                    </script>
                    <!--状态模板-->
                    <script type="text/html" id="staBar">
                        {{# switch(d["user_auth_status"]) { case 1: }}
                            <span class="layui-badge layui-bg-orange">未认证</span>
                        {{# break; case 2: }}
                            <span class="layui-badge layui-bg-blue">待审核</span>
                        {{# break; case 3: }}
                            <span class="layui-badge">认证失败</span>
                        {{# break; default: }}
                            <span class="layui-badge layui-bg-green">认证成功</span>
                        {{# break; } }}

                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        {{# if(d.user_auth_status == 2){ }}
                        <a href="javascript:;" onclick="agreeshop('{{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="审核"><i class="fa fa-pencil"></i></a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('memberDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除"><i class="fa fa-trash-o"></i></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Member/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , even: false //开启隔行背景
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type:'numbers', width: 80, title: '序号'}
                , {field: 'user_username', width: '', title: '用户名', align: 'center'}
                , {field: 'user_image', width: 90, title: '头像', align: 'center', templet: '#imgTpl'}
                , {field: 'user_rel_name', width: '', title: '真实姓名', align: 'center'}
                , {field: 'user_id_number', width: '', title: '身份证号', align: 'center'}
                , {field: 'user_time', width: '', title: '注册时间', align: 'center'}
                , {fixed: 'right', width: 100, title: '状态',align: 'center', templet: '#staBar'}
                , {fixed: 'right', width: 100, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
    });
    function agreeshop(id){
        layer.confirm('审核通过吗？', {
            btn: ['通过','驳回'] //按钮
        }, function(){
            shopchange(4,id,"{:url('agreeUser')}")
        }, function(){
            shopchange(3,id,"{:url('agreeUser')}")
        });
    }
    function shopchange(type,id,url){
        $.ajax({
            url: url,
            type:'post',
            data:'type='+type+'&id='+id,
            dataType:'json',
            success:function(res){
                if(res.code == 200){
                    layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                        //重载当前页表格
                        $(".layui-laypage-btn").click();
                    })
                }else if(res.code == 100){
                    wk.error(res.msg,'',2);
                }
            }
        })
    }
</script>
</body>
</html>